//
//  XMLParser.h
//  Portable Traffic Signal Assistor
//
//  Created by Hao Xu on 4/1/12.
//  Copyright (c) 2012 TTU. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "GDataXMLNode.h"
#import "TimerGroup.h"
#import "Signal.h"
#import "SignalRing.h"
#import "SignalPhase.h"
#import "Agency.h"
#import "SubSystem.h"
#import "TimingPattern.h"
#import "TimeRange.h"
#import "Link.h"
#import "Intersection.h"
#import "NEMASignal.h"
#import "PropertyReadingWritingClass.h"
@interface XMLParser : NSObject
//@property (nonatomic, retain) NSString * fileName;

+ (BOOL) changeDataXML:(NSString *) xmlFileName;
+ (BOOL) loadDataXML;
+ (BOOL) loadTempXML;
+ (NSString *)dataTempFilePath;
+ (BOOL) saveDataXML;
+ (BOOL) createNewProject;



//Operations of agency
+ (BOOL) createAgency: (Agency *) agency;
+ (BOOL) removeAgency: (Agency *) agency;
+ (NSArray *) getAgencyList;
+ (Agency *) getAgencyByAgencyID: (NSString *) agencyID;
+ (BOOL) updateAgency: (Agency *) agency;
+ (NSString *) createAgencyID;


//Operations of subSystem
+ (BOOL) createSubSystem:(SubSystem *)subSystem;
+ (BOOL) removeSubSystem:(SubSystem *)subSystem;
+ (NSArray *) getSubSystemListofAgency:(Agency *)agency;
+ (NSArray *) getSubSystemListbyAgencyID:(NSString *)agencyID;
+ (SubSystem *) getSubSystemofAgency:(NSString *)subSystemID agency:(Agency *)agency;
+ (SubSystem *) getSubSystembyAgencyID:(NSString *)subSystemID agencyID:(NSString *)agencyID;
+(BOOL) updateSubSystem: (SubSystem *) subSystem;
+ (NSString *) createSubSystemID:(Agency *)agency;

//Operations of timingPattern
+ (BOOL) createTimingPattern:(TimingPattern *)timingPattern ;
+ (TimingPattern *) duplicateTimingPattern:(TimingPattern *)timingPattern ;
+ (BOOL) removeTimingPattern:(TimingPattern *)timingPattern ;
+ (NSArray *) getTimingPatternListofSubSystem:(SubSystem *)subSystem;
+ (NSArray *) getTimingPatternList:(NSString *)subSystemID agencyID:(NSString *)agencyID;
+ (TimingPattern *) getTimingPatternofSubSystem:(NSString *)timingPatternID subSystem:(SubSystem *)subSystem ;
+ (TimingPattern *) getTimingPattern:(NSString *)timingPatternID subSystemID:(NSString *)subSystemID agencyID:(NSString *)agencyID ;
+ (BOOL) updateTimingPattern:(TimingPattern *)timingPattern ;
+ (NSString *) createTimingPatternID:(SubSystem *)subSystem;

//Operations of intersections
+ (BOOL)createIntersection:(Intersection *) intersection;
+ (BOOL) removeIntersection:(Intersection *) intersection ;
+ (NSArray *) getIntersectionList:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (NSArray *) getIntersectionListofSubSystem:(SubSystem *)subSystem;
+ (Intersection *) getIntersection:(NSString *) intersectionID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (Intersection *) getIntersectionofSubSystem:(NSString *) intersectionID subSystem:(SubSystem *) subSystem;
+ (BOOL) updateIntersection:(Intersection *) intersection;
+ (NSString *) createIntersectionID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (NSString *) createIntersectionIDofSubSystem:(SubSystem *)subSystem;

//Operations of links
+ (BOOL)createLink:(Link *) link;
+ (BOOL) removeLink:(Link *) link;
+ (NSArray *) getLinkList:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (NSArray *) getLinkListofSubSystem:(SubSystem *) subSystem;
+ (NSArray *) getLinkListFromIntersectionbyIDs:(NSString *)agencyID subSystemID:(NSString *)subSystemID intersectionID:(NSString *) intersectionID;
+ (NSArray *) getLinkListFromIntersection:(Intersection *)intersection;
+ (NSArray *) getLinkListToIntersectionbyIDs:(NSString *)agencyID subSystemID:(NSString *)subSystemID intersectionID:(NSString *) intersectionID;
+ (NSArray *) getLinkListToIntersection:(Intersection *)intersection;
+ (Link *) getLink:(NSString *) linkID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID;
+ (Link *) getLinkofSubSystem:(NSString *)linkID subSystem:(SubSystem *) subSystem;
+ (BOOL) updateLink:(Link *) link;
+ (NSString *) createLinkID:(NSString *)agencyID subSystemID:(NSString *)subSystemID ;
+ (NSString *) createLinkIDofSubSystem:(SubSystem *)subSystem;


//Operations of signals
+ (BOOL)createSignal:(Signal *) signal;
+ (BOOL) removeSignal:(Signal *) signal;
+ (BOOL) removeSignalbyIDs:(NSString *) signalID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (NSArray *) getSignalList:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (NSArray *) getSignalListofTimingPattern:(TimingPattern *)timingPattern;
+ (Signal *) getSignal:(NSString *) signalID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (Signal *) getSignalofTimingPattern:(NSString *) signalID timingPattern:(TimingPattern *)timingPattern;
+ (BOOL) updateSignal:(Signal *) signal;
+ (NSString *) createSignalID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (NSString *) createSignalIDofTimingPattern:(TimingPattern *)timingPattern;




//Operations of phases
+ (BOOL)createPhase:(SignalPhase *) phase signal:(Signal *)signal;
+ (BOOL) removePhase:(SignalPhase *) phase signal:(Signal *)signal;
//+ (NSArray *) getPhaseList:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID;
//+ (SignalPhase *) getPhase:(NSString *) phaseID agencyID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID;
+ (BOOL) updatePhase:(SignalPhase *) phase signal:(Signal *)signal;
//+ (NSString *) createSignalID:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID;
+ (BOOL) clearPhases:(NSString *)agencyID subSystemID:(NSString *)subSystemID timingPatternID:(NSString *)timingPatternID signalID:(NSString *)signalID;


@end
